<!--@ 首页 -->
<template>
	<view class="bg-white" >
		<u-notify ref="uNotify" />
		
		<view class="cu-bar bg-white  margin-top-xs" v-if="dataFrom.workDetails && dataFrom.workDetails.length">
			<!-- <view class="action">
				<text class="cuIcon-title text-cyan"></text>
				<text
					class="text-df text-cyan text-bold">{{`个人日报列表`}}
					<text class="text-red text-df text-bold padding-left-xs" >
						{{`( ${ dataSource.length} )`}}
					</text>
					</text>
			</view> -->
			<view class="action">
				<view class="cu-btn sm bg-cyan" @click="handeNew()">添加日报</view>
			</view>
		</view>
		<uni-table ref="table" v-if="dataSource.length >0" :loading="loading" border
			emptyText="暂无更多数据" uni-table @selection-change="selectionChange" style="height: 1400rpx;overflow-y: auto;">
			<uni-tr>
				<uni-th width="40" align="center">
					<view class="text-xs">序号</view>
				</uni-th>
				<uni-th width="80" align="center">
					<view class="text-xs">时间</view>
				</uni-th>
				<uni-th width="130" align="center">
					<view class="text-xs">日报标题</view>
				</uni-th>

				<uni-th align="center" width="70">
					<view class="text-xs">负责人</view>
				</uni-th>
				<!-- 				<uni-th align="center">
					<view class="text-xs">截止时间</view>
				</uni-th> -->
				<uni-th align="center" width="100">
					<view class="text-xs">操作</view>
				</uni-th>
			</uni-tr>
			<uni-tr v-for="(item, index) in dataSource" :key="index"
				v-if="dataSource.length>0"
				:class="item.state ==1 || item.selfOk ==1?'box' :''">
				<uni-td align="center">
					<view class="cu-avatar sm round  bg-cyan"
						>{{ dataSource.length - index}}
					</view>
				</uni-td>
				<uni-td align="center">
						<view class="text-xs">{{ item.orderDate }}</view>
					
				</uni-td>
				<uni-td align="center">
				<view class="text-xs">{{ item.dailyTitle }}</view>
				</uni-td>
				<uni-td align="center">
					<view class="text-xs">{{ item.username }}</view>
				</uni-td>
				<uni-td align="center">
						<view class="cu-btn sm round bg-yellow"  @click="handeRemack(item)">详情</view>
					
				</uni-td>

			</uni-tr>
		</uni-table>
		<remarkMode ref="remarkFrom" @ok="loadData" />
		<paperMode ref="paperRef" @ok="loadData"  />
	</view>
</template>
<script>
	import loadFlex from '@/components/loadFlex/loadFlex.vue' //加载框
	import remarkMode from '@/components/remarkMode.vue' //备注
	import paperMode from '@/components/paperMode.vue' //新增
	import myApi from '@/utils/app.js' //调用接口使
	export default {
		name: 'progressFrom.vue',
		components: {
			loadFlex,
			remarkMode,
			paperMode,
		},
		props: {
			ShowAdmin: {
				type: Boolean,
				default: false
			},
			dataFrom:{
				type: Object,
				default: () => {}
			},
			dataSource: { // 课程 数据
							type: Array,
							default: () => []
						},
		},
		data() {
			return {
				loading: false,
				searchVal: '',
				tableData: [],
				// 每页数据量
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				model: {},
			}
		},
		computed: {
			handItyCard() {
				return function(text) {
					if (text) return text.split(",")
					return []
				}
			},
		},
		methods: {
			async loadData(index) {
				this.$emit('ok',1)
			},
			handeRemack(item) {
				uni.navigateTo({ // 今日拨打次数
					url: `/pages/details/details?projectId=${item.id}`,
				})
			},
			handeComplete(item) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认自我确定吗？',
					success: function(res) {
						if (res.confirm) that.handeNoApply(item)
					},
				})
			},
			onNotify(round) {
				this.$refs.uNotify.show({
					type: round.type ? round.type : 'success',
					message: round.message ? round.message : '删除成功',
					top: 50
				})
			},
			async handeNoApply(item) {
				this.loading == true
				try {
					const res = await this.$request({
						url: myApi.selfOk,
						method: 'post',
						data: {
							orderNo: item.orderId,
							vto: {
								id: item.id
							}
						},
					});
					console.log(res)
					if (res.code == 200) {
						this.loadData()
						setTimeout(() => (
							this.onNotify({
								message: '操作成功'
							})), 1000);
					}
				} catch (e) {
					// 失败执行

				} finally {
					// 销毁执行
					this.loading = false
				}
			},
			handeImage(index,item) {
				console.log(item)
				const  imgs = item.split(",").map(item => {
					//只返回图片路径
					return item
				})
				console.log(imgs);
				//调用预览图片的方法
				uni.previewImage({
					urls: imgs,
					current: index
				})
			
			},
			handeNew(){
				this.$refs.paperRef.onNew(this.dataFrom.workDetails[0])
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		background-color: #CBEDED;
	}
</style>